﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace debugger
{
    public class Key
    {
      
        public static uint getKey(Keys keyCode, bool down, int LParam)
        {
            uint key = 0;
            int val = ((int)keyCode);
            //Console.WriteLine((down ? "D----------------------" : "U----------------------") + Util.getHex8(val));
            switch (val & 0xFF)
            {

                case 0x0000001b: key = down ? 0x82000076 : 0x820076F0; break;//0x82000076 : 0x820076F0                       83002900 83000000 esc
                case 0x00000070: key = down ? 0x82000005 : 0x820005F0; break;//0x82000005 : 0x820005F0                       83003A00 83000000 f1
                case 0x00000071: key = down ? 0x82000006 : 0x820006F0; break;//0x82000006 : 0x820006F0                       83003B00 83000000 2
                case 0x00000072: key = down ? 0x82000004 : 0x820004F0; break;//0x82000004 : 0x820004F0                       83003C00 83000000 3
                case 0x00000073: key = down ? 0x8200000C : 0x82000CF0; break;//0x8200000C : 0x82000CF0                       83003D00 83000000 4
                case 0x00000074: key = down ? 0x82000003 : 0x820003F0; break;//0x82000003 : 0x820003F0                       83003E00 83000000 5
                case 0x00000075: key = down ? 0x8200000B : 0x82000BF0; break;//0x8200000B : 0x82000BF0                       83003F00 83000000 6
                case 0x00000076: key = down ? 0x82000083 : 0x820083F0; break;//0x82000083 : 0x820083F0                       83004000 83000000 7
                case 0x00000077: key = down ? 0x8200000A : 0x82000AF0; break;//0x8200000A : 0x82000AF0                       83004100 83000000 8
                case 0x00000078: key = down ? 0x82000001 : 0x820001F0; break;//0x82000001 : 0x820001F0                       83004200 83000000 9
                case 0x00000079: key = down ? 0x82000009 : 0x820009F0; break;//0x82000009 : 0x820009F0                       83004300 83000000 10
                case 0x0000007a: key = down ? 0x82000078 : 0x820078F0; break;//0x82000078 : 0x820078F0                       83004400 83000000 11
                case 0x0000007b: key = down ? 0x82000007 : 0x820007F0; break;//0x82000007 : 0x820007F0                       83004500 83000000 12

                case 0x0000002C: key = down ? 0x82007CE0 : 0x8212F0E0; break;//82007CE0 8212F0E0                       83004600 83000000 printsc
                case 0x00000091: key = down ? 0x8200007E : 0x82007EF0; break;//8200007E 82007EF0                       83004700 83000000 sc lock
                case 0x00000013: key = down ? 0x821477F0 : 0x821477F0; break;//821477F0 821477F0 8214F0F0 82007700     83004800 83000000 pause break

                case 0x000000c0: key = down ? 0x8200000E : 0x82000EF0; break;//0x8200000E : 0x82000EF0                       83003500 83000000 `
                case 0x00000031: key = down ? 0x82000016 : 0x820016F0; break;//0x82000016 : 0x820016F0                       83001E00 83000000 1
                case 0x00000032: key = down ? 0x8200001E : 0x82001EF0; break;//0x8200001E : 0x82001EF0                       83001F00 83000000 2
                case 0x00000033: key = down ? 0x82000026 : 0x820026F0; break;//0x82000026 : 0x820026F0                       83002000 83000000 3
                case 0x00000034: key = down ? 0x82000025 : 0x820025F0; break;//0x82000025 : 0x820025F0                       83002100 83000000 4
                case 0x00000035: key = down ? 0x8200002E : 0x82002EF0; break;//0x8200002E : 0x82002EF0                       83002200 83000000 5
                case 0x00000036: key = down ? 0x82000036 : 0x820036F0; break;//0x82000036 : 0x820036F0                       83002300 83000000 6
                case 0x00000037: key = down ? 0x8200003D : 0x82003DF0; break;//0x8200003D : 0x82003DF0                       83002400 83000000 7
                case 0x00000038: key = down ? 0x8200003E : 0x82003EF0; break;//0x8200003E : 0x82003EF0                       83002500 83000000 8
                case 0x00000039: key = down ? 0x82000046 : 0x820046F0; break;//0x82000046 : 0x820046F0                       83002600 83000000 9
                case 0x00000030: key = down ? 0x82000045 : 0x820045F0; break;//0x82000045 : 0x820045F0                       83002700 83000000 0
                case 0x000000bd: key = down ? 0x8200004E : 0x82004EF0; break;//0x8200004E : 0x82004EF0                       83002D00 83000000 -
                case 0x000000bb: key = down ? 0x82000055 : 0x820055F0; break;//0x82000055 : 0x820055F0                       83002E00 83000000 =
                case 0x00000008: key = down ? 0x82000066 : 0x820066F0; break;//0x82000066 : 0x820066F0                       83002A00 83000000 ba sp

                case 0x00000009: key = down ? 0x8200000D : 0x82000DF0; break;//0x8200000D : 0x82000DF0                       83002B00 83000000 tab
                case 0x00000051: key = down ? 0x82000015 : 0x820015F0; break;//0x82000015 : 0x820015F0                       83001400 83000000 q
                case 0x00000057: key = down ? 0x8200001D : 0x82001DF0; break;//0x8200001D : 0x82001DF0                       83001A00 83000000 w
                case 0x00000045: key = down ? 0x82000024 : 0x820024F0; break;//0x82000024 : 0x820024F0                       83000800 83000000 e
                case 0x00000052: key = down ? 0x8200002D : 0x82002DF0; break;//0x8200002D : 0x82002DF0                       83001500 83000000 r
                case 0x00000054: key = down ? 0x8200002C : 0x82002CF0; break;//0x8200002C : 0x82002CF0                       83001700 83000000 t
                case 0x00000059: key = down ? 0x82000035 : 0x820035F0; break;//0x82000035 : 0x820035F0                       83001C00 83000000 y
                case 0x00000055: key = down ? 0x8200003C : 0x82003CF0; break;//0x8200003C : 0x82003CF0                       83001800 83000000 u
                case 0x00000049: key = down ? 0x82000043 : 0x820043F0; break;//0x82000043 : 0x820043F0                       83000C00 83000000 i
                case 0x0000004f: key = down ? 0x82000044 : 0x820044F0; break;//0x82000044 : 0x820044F0                       83001200 83000000 o
                case 0x00000050: key = down ? 0x8200004D : 0x82004DF0; break;//0x8200004D : 0x82004DF0                       83001300 83000000 p
                case 0x000000db: key = down ? 0x82000054 : 0x820054F0; break;//0x82000054 : 0x820054F0                       83002F00 83000000 [
                case 0x000000dd: key = down ? 0x8200005B : 0x82005BF0; break;//0x8200005B : 0x82005BF0                       83003000 83000000 ]
                case 0x000000dc: key = down ? 0x8200005D : 0x82005DF0; break;//0x8200005D : 0x82005DF0                       83003100 83000000 \

                case 0x00000014: key = down ? 0x82000058 : 0x820058F0; break;//0x82000058 : 0x820058F0                       83003900 83000000 cap lock
                case 0x00000041: key = down ? 0x8200001C : 0x82001CF0; break;//0x8200001C : 0x82001CF0                       83000400 83000000 a
                case 0x00000053: key = down ? 0x8200001B : 0x82001BF0; break;//0x8200001B : 0x82001BF0                       83001600 83000000 s
                case 0x00000044: key = down ? 0x82000023 : 0x820023F0; break;//0x82000023 : 0x820023F0                       83000700 83000000 d
                case 0x00000046: key = down ? 0x8200002B : 0x82002BF0; break;//0x8200002B : 0x82002BF0                       83000900 83000000 f
                case 0x00000047: key = down ? 0x82000034 : 0x820034F0; break;//0x82000034 : 0x820034F0                       83000A00 83000000 g
                case 0x00000048: key = down ? 0x82000033 : 0x820033F0; break;//0x82000033 : 0x820033F0                       83000B00 83000000 h
                case 0x0000004a: key = down ? 0x8200003B : 0x82003BF0; break;//0x8200003B : 0x82003BF0                       83000D00 83000000 j
                case 0x0000004b: key = down ? 0x82000042 : 0x820042F0; break;//0x82000042 : 0x820042F0                       83000E00 83000000 k
                case 0x0000004c: key = down ? 0x8200004B : 0x82004BF0; break;//0x8200004B : 0x82004BF0                       83000F00 83000000 l
                case 0x000000ba: key = down ? 0x8200004C : 0x82004CF0; break;//0x8200004C : 0x82004CF0                       83003300 83000000 ;
                case 0x000000de: key = down ? 0x82000052 : 0x820052F0; break;//0x82000052 : 0x820052F0                       83003400 83000000 '
                case 0x0000000d: key = down ? 0x8200005A : 0x82005AF0; break;//0x8200005A : 0x82005AF0                       83002800 83000000 enter

                case 0x00000010: key = down ? 0x82000012 : 0x820012F0; break;//0x82000012 : 0x820012F0                       83020000 83000000 lshift

                case 0x0000005a: key = down ? 0x8200001A : 0x82001AF0; break;//0x8200001A : 0x82001AF0                       83001D00 83000000 z
                case 0x00000058: key = down ? 0x82000022 : 0x820022F0; break;//0x82000022 : 0x820022F0                       83001B00 83000000 x
                case 0x00000043: key = down ? 0x82000021 : 0x820021F0; break;//0x82000021 : 0x820021F0                       83000600 83000000 c
                case 0x00000056: key = down ? 0x8200002A : 0x82002AF0; break;//0x8200002A : 0x82002AF0                       83001900 83000000 v
                case 0x00000042: key = down ? 0x82000032 : 0x820032F0; break;//0x82000032 : 0x820032F0                       83000500 83000000 b
                case 0x0000004e: key = down ? 0x82000031 : 0x820031F0; break;//0x82000031 : 0x820031F0                       83001100 83000000 n
                case 0x0000004d: key = down ? 0x8200003A : 0x82003AF0; break;//0x8200003A : 0x82003AF0                       83001000 83000000 m
                case 0x000000bc: key = down ? 0x82000041 : 0x820041F0; break;//0x82000041 : 0x820041F0                       83003600 83000000 ,
                case 0x000000be: key = down ? 0x82000049 : 0x820049F0; break;//0x82000049 : 0x820049F0                       83003700 83000000 .
                case 0x000000bf: key = down ? 0x8200004A : 0x82004AF0; break;//0x8200004A : 0x82004AF0                       83003800 83000000 /
                //case 0x00010010: key = down ?0x82000059 : 0x820059F0; break;//0x82000059 : 0x820059F0                       83200000 83000000 rshift

                case 0x00020011: key = down ? 0x82000014 : 0x820014F0; break;//0x82000014 : 0x820014F0                       83010000 83000000 ctl
                //case : key = 0x66; break;//0x82001FE0 : 0x821FF0E0                       83080000 83000000 win
                //case : key = 0x66; break;//0x82000011 : 0x820011F0                       83040000 83000000 alt
                case 0x00000020: key = down ? 0x82000029 : 0x820029F0; break;//0x82000029 : 0x820029F0                       83002C00 83000000 spac
                //case : key = 0x66; break;//0x820011E0 : 0x8211F0E0                       83400000 83000000 alt
                //case : key = 0x66; break;//0x820027E0 : 0x8227F0E0                       83800000 83000000 win
                //case 0000005d: key = 0x66; break;//0x82002FE0 : 0x822FF0E0                       83006500 83000000 menu
                //case 00020011: key = 0x66; break;//0x820014E0 : 0x8214F0E0                       83100000 83000000 ctrl

                case 0x0000002d: key = down ? 0x820070E0 : 0x8270F0E0; break;//0x820070E0 : 0x8270F0E0                       83004900 83000000 insert
                case 0x00000024: key = down ? 0x82006CE0 : 0x826CF0E0; break;//0x82006CE0 : 0x826CF0E0                       83004A00 83000000 home
                case 0x00000021: key = down ? 0x82007DE0 : 0x827DF0E0; break;//0x82007DE0 : 0x827DF0E0                       83004B00 83000000 pu
                case 0x0000002e: key = down ? 0x820071E0 : 0x8271F0E0; break;//0x820071E0 : 0x8271F0E0                       83004C00 83000000 del
                case 0x00000023: key = down ? 0x820069E0 : 0x8269F0E0; break;//0x820069E0 : 0x8269F0E0                       83004D00 83000000 end
                case 0x00000022: key = down ? 0x82007AE0 : 0x827AF0E0; break;//0x82007AE0 : 0x827AF0E0                       83004E00 83000000 pd

                case 0x00000026: key = down ? 0x820075E0 : 0x8275F0E0; break;//0x820075E0 : 0x8275F0E0 up                    83005200 83000000 up
                case 0x00000028: key = down ? 0x820072E0 : 0x8272F0E0; break;//0x820072E0 : 0x8272F0E0 down                  83005100 83000000 down
                case 0x00000025: key = down ? 0x82006BE0 : 0x826BF0E0; break;//0x82006BE0 : 0x826BF0E0 left                  83005000 83000000 left
                case 0x00000027: key = down ? 0x820074E0 : 0x8274F0E0; break;//0x820074E0 : 0x8274F0E0 right                 83004F00 83000000 right

                //case 0x00000090: key = down ? 0x82000077 : 0x820077F0; break;//0x82000077 : 0x820077F0 num                   83005300 83000000 num
                //case 0x0000006f: key = down ? 0x82004AE0 : 0x824AF0E0; break;//0x82004AE0 : 0x824AF0E0 /                     83005400 83000000 /
                //case 0x0000006a: key = down ? 0x8200007C : 0x82007CF0; break;//0x8200007C : 0x82007CF0 *                     83005500 83000000 *
                //case 0x0000006d: key = down ? 0x8200007B : 0x82007BF0; break;//0x8200007B : 0x82007BF0 -                     83005600 83000000 -
                //case 0x00000024: key = down ? 0x8200006C : 0x82006CF0; break;//0x8200006C : 0x82006CF0 7                     83005F00 83000000 789
                //case 0x00000026: key = down ? 0x82000075 : 0x820075F0; break;//0x82000075 : 0x820075F0 8                     83006000 83000000 
                //case 0x00000021: key = down ? 0x8200007D : 0x82007DF0; break;//0x8200007D : 0x82007DF0 9                     83006100 83000000 
                //case 0x0000006b: key = down ? 0x82000079 : 0x820079F0; break;//0x82000079 : 0x820079F0 +                     83005700 83000000 +
                //case 0x00000025: key = down ? 0x8200006B : 0x82006BF0; break;//0x8200006B : 0x82006BF0 4                     83005C00 83000000 456
                //case 0x0000000c: key = down ? 0x82000073 : 0x820073F0; break;//0x82000073 : 0x820073F0 5                     83005D00 83000000 
                //case 0x00000027: key = down ? 0x82000074 : 0x820074F0; break;//0x82000074 : 0x820074F0 6                     83005E00 83000000 
                //case 0x00000023: key = down ? 0x82000069 : 0x820069F0; break;//0x82000069 : 0x820069F0 1                     83005900 83000000 123
                //case 0x00000028: key = down ? 0x82000072 : 0x820072F0; break;//0x82000072 : 0x820072F0 2                     83005A00 83000000 
                //case 0x00000022: key = down ? 0x8200007A : 0x82007AF0; break;//0x8200007A : 0x82007AF0 3                     83005B00 83000000 
                //case 0x0000000d: key = down ? 0x82005AE0 : 0x825AF0E0; break;//0x82005AE0 : 0x825AF0E0 enter                 83005800 83000000 enter
                //case 0x0000002d: key = down ? 0x82000070 : 0x820070F0; break;//0x82000070 : 0x820070F0 0                     83006200 83000000 0
                //case 0x0000002e: key = down ? 0x82000071 : 0x820071F0; break;//0x82000071 : 0x820071F0 .                     83006300 83000000 .
                

            }
            return key;
        }
    }
}